package app.server.services

import app.server.ServerActor
import net.liftweb.http._
import org.joda.time.DateTimeZone._
import org.joda.time.{DateTime, LocalDate, LocalDateTime}
import im.mange.shoreditch.engine.{RealClock, Clock, EngineActor}
import akka.actor.{ActorRef, Props, ActorSystem}

object ServiceFactory extends Factory {
  val actorSystem  = ActorSystem.create()

  lazy val clockInstance: Clock = RealClock
  lazy val engineActorInstance: ActorRef = actorSystem.actorOf(Props(new EngineActor))
  lazy val serverActorInstance: ServerActor = new ServerActor

  implicit object systemClock extends FactoryMaker(() ⇒ clockInstance)
  implicit object serverActor extends FactoryMaker(() ⇒ serverActorInstance)
  implicit object engineActor extends FactoryMaker(() ⇒ engineActorInstance)

  def startup() {
    serverActorInstance
  }

  def shutdown() {}
}